﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XcoAppSpaces.Contracts.Communication;
using XcoAppSpaces.Contracts.Security;
using XcoAppSpaces.Contracts.Transport;
using XcoAppSpaces.Contracts.Worker;
using XcoAppSpaces.Contracts.Service;

namespace XcoAppSpaces.Core
{
	/// <summary>
	/// Class that presents meta information about the space.
	/// </summary>
	public class XcoSpaceInfo
	{
		/// <summary>
		/// Information about the workers of this space instance.
		/// </summary>
		public IEnumerable<XcoWorkerInfo> Workers { get; private set; }

		/// <summary>
		/// The service registry of the space, allowing access to all its running services.
		/// </summary>
		public IXcoServiceRegistry ServiceRegistry { get; private set; }

		/// <summary>
		/// Information about the communication services of this space instance.
		/// </summary>
		public IEnumerable<XcoServiceConfiguration<IXcoTransportService>> TransportServices { get; private set; }

		/// <summary>
		/// The security service that is used by this space instance.
		/// </summary>
		public IXcoSecurityService SecurityService { get; private set; }

		/// <summary>
		/// Events giving information about incoming and outgoing communication, e.g. for monitoring
		/// </summary>
		public ICommunicationEvents CommunicationEvents { get; private set; }


		internal XcoSpaceInfo(IEnumerable<XcoWorkerInfo> workers, IEnumerable<XcoServiceConfiguration<IXcoTransportService>> transportServices, IXcoServiceRegistry serviceRegistry)
		{
			this.Workers = workers;
			this.ServiceRegistry = serviceRegistry;
			this.TransportServices = transportServices;
			this.SecurityService = serviceRegistry.Resolve<IXcoSecurityService>();
			this.CommunicationEvents = serviceRegistry.Resolve<IConnector>().CommunicationEvents;
		}
	}
}
